package com.qianfeng.teachdemo.eventBus;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;


import com.lidroid.event.EventBus;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.qianfeng.teachdemo.R;
import com.qianfeng.teachdemo.ui.BaseActivity;

public class PostEventActivity extends BaseActivity {
    EventBus eventBus = EventBus.getDefault();
    @ViewInject(R.id.post_event_btn)
    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewUtils.inject(this);
        eventBus.register(this);
    }

    // 主线程的监听（另外四种方式如下）
    public void onEventMainThread(int num) {
        num++;
        Toast.makeText(this, num, Toast.LENGTH_SHORT).show();
    }


    @OnClick(R.id.post_event_btn)
    public void onClick(View v) {
        eventBus.post(10);
        this.finish();
    }
}
